#include<iostream>
using namespace std;
struct A{
	int year;
	int month;
	int day;
};
bool is_run(int year){
	if(year%4==0&&year%100!=0||year%400==0){
		return true;
	}else{
		return false;
	}
}
int main(){
	A a;
	int sum=0;
	scanf("%d%d%d",&a.year,&a.month,&a.day);
	for(int i=1;i<a.month;i++){
		switch(i){
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				sum+=31;
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				sum+=30;
				break;
			case 2:
				if(is_run(a.year)){
					sum+=29;
				}else{
					sum+=28;
				}
		}
	}
	printf("%d\n",sum+a.day);
	return 0;
} 
